package cn.edu.wynu;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * 通过配置类配置
 */
public class TestConfigClassQuery {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JdbcConfig.class);
        JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
        // 查询列表
        List<Employee> employees = jdbcTemplate.query("select * from t_emp",
                new BeanPropertyRowMapper<>(Employee.class));

        System.out.println(employees);
    }
}
